<?php
my_component_load('testing' , false);
my_component_load('paging' , false);
my_component_load('data_keluarga');
$task = isset($_GET['task']) ? $_GET['task'] : ""; 
$id = isset( $_GET['id'] ) ? $_GET['id']:  0;
$kid = isset( $_GET['kid'] ) ? $_GET['kid']:  0;

if($_SERVER['REQUEST_METHOD'] == "POST" ):
	switch($task){
		case   "create" :
		case   "edit" :
			form_submit_data_keluarga($id);
			$content =  "Updated";
		break;
		
		case "edit_page":  
			form_edit_data_keluarga_submit($id);
			$content =  "Updated";
			generate_my_web($content,"","plain.php");
			exit;		
		break;
	}

else: 	
	$_SESSION['tab_page'] = '#tab5';
	if($task == "create"){
		$pagename = "Data anggota keluarga";
		$content = form_create_data_keluarga();
	}elseif($task == "edit"){
		$pagename = "Edit data karyawan";
		$content = form_create($id);
	}elseif($task == "edit_page"){ 
		$content  = form_edit_data_keluarga( $id );
		generate_my_web($content,"","plain.php");
		exit;		
	}elseif($task == 'edit_popup'){	
		$title= ($aid > '0' ) ?  "Perubahan data hubungan keluarga" : "Tambah data hubungan keluarga";
		facebox_page('index.php?com=data_keluarga&task=edit_page&kid='.$kid.'&id='.$id  , $title , 290	); 
	
	}elseif($task == "excel"){
		
		my_component_load('xl_builder' , false);
		header("Content-Type: application/xls");
		header("Content-Disposition: attachment;filename=data_keluarga_karyawan.xls");
		echo excel_data_keluarga();
		exit;
	
	}elseif($task == "detail"){
		$karyawan = loaddata_karyawan($id);
		$pagename = "Detail data karyawan ".$karyawan['nama'];
		$content = form_detail($id);
	}else{
		$pagename = "Daftar karyawan";
		load_facebox_script();
		$content = report_karyawan();
	}
endif; 
generate_my_web($content, $pagename  );
?>